﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Display;

namespace GISCommon.UI
{
    public partial class FindForm : Form
    {
        #region 公有方法

            #region 构造函数

        /// <summary>
        /// 描述：构造函数

        /// </summary>
        public FindForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 描述：构造函数

        /// </summary>
        /// <param name="pMapControl">地图控件</param>
        public FindForm(AxMapControl pMapControl)
        {
            InitializeComponent();

            m_pMapControl = pMapControl;
        }
            #endregion

        #endregion

        #region 私有方法

            #region 初始化函数

        /// <summary>
        /// 描述：初始化函数
        /// </summary>
        private void Initial()
        {
            try
            {
                //地图控件判断
                if (m_pMapControl == null)
                {
                    MessageBox.Show("未设置地图控件MapControl属性！");
                    return;
                }

                m_pMapControl.OnExtentUpdated += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnExtentUpdatedEventHandler(this.m_pMapControl_OnExtentUpdated);
                //m_pMapControl.OnAfterDraw += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnAfterDrawEventHandler(this.m_pMapControl_OnAfterDraw);
                
                //初始化identity
                identity.Initial(m_pMapControl);

                //初始化CombolBox
                cbb_In.Text = "所有图层";
                cbb_In.Items.Add("所有图层");
                int intCount;
                intCount = m_pMapControl.LayerCount;
                int intTemp;
                for (intTemp = 0; intTemp < intCount; intTemp++)
                {
                    cbb_In.Items.Add(m_pMapControl.get_Layer(intTemp).Name.ToString());
                }
                //if(m_pMapControl.get_Layer(0)!=null)
                //    cbb_In.Text = m_pMapControl.get_Layer(0).Name.ToString();

                //设置查询结果
                lvw_Result.Columns.Add("值", 3 * lvw_Result.Width / 10);
                lvw_Result.Columns.Add("图层", 6 * lvw_Result.Width / 10);
                //lvw_Result.Columns.Add("字段", 3 * lvw_Result.Width / 10);
                //设置按钮的可用性

                btn_Info.Enabled = false;
                btn_Locate.Enabled = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用Initial出错，" + ex.Message.ToString());
            }
        }

        /// <summary>
        /// 描述：初始化函数
        /// </summary>
        /// <param name="pMapControl">地图控件</param>
        private void Initial(AxMapControl pMapControl)
        {
            try
            {
                m_pMapControl = pMapControl;
                Initial();
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用Initial()出错，" + ex.Message.ToString());
            }
        }
        #endregion

            #region 判断输入的字符串是否数字
        /// <summary>
        /// 描述：判断输入的字符串是否数字

        /// </summary>
        /// <param name="InStr">要判断的字符串</param>
        /// <returns>是返回true，否则返回false</returns>
        private bool IsNumber(string InStr)
        {
            try
            {
                bool IsNum = true;
                string tmpStr;
                for (int i = 0; i <= InStr.Length - 1; i++)
                {
                    tmpStr = InStr.Substring(i, 1);
                    if (!Char.IsNumber(tmpStr, 0))
                    {
                        IsNum = false;
                        break;
                    }
                }
                return IsNum;
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用IsNumber出错，" + ex.Message.ToString());
                return false;
            }
        }
            #endregion

            #region 执行查找操作
        /// <summary>
        /// 描述：执行查找操作

        /// </summary>
        private void FindInfo()
        {
            try
            {
                //获取查找内容
                string strFindText = cbb_Find.Text.Trim();
                if (strFindText == "")
                {
                    MessageBox.Show("请输入查找内容！", "查找");
                    return;
                }

                //设置按钮可用属性

                btn_Find.Text = "正在查找...";
                btn_Find.Enabled = false;

                //清除上次查询结果的内容

                lvw_Result.Items.Clear();
                if (m_altFeature == null)
                {
                    m_altFeatureLayer = new System.Collections.ArrayList();
                    m_altFeature = new System.Collections.ArrayList();
                }
                else
                {
                    m_altFeatureLayer = null;
                    m_altFeature = null;
                    m_altFeatureLayer = new System.Collections.ArrayList();
                    m_altFeature = new System.Collections.ArrayList();
                }

                ////获取查找内容
                //string strFindText = cbb_Find.Text.Trim();
                //if (strFindText == "")
                //{
                //    MessageBox.Show("请输入查找内容！", "查找");
                //    return;
                //}

                if (!cbb_Find.Items.Contains(strFindText))
                    cbb_Find.Items.Add(strFindText);

                //获取查找范围
                string strInText = cbb_In.Text.Trim();

                //目标图层
                int c = m_pMapControl.LayerCount;  //图层数量
                ILayer[] pLayer;
                System.Collections.ArrayList altLayer = new System.Collections.ArrayList();
                int intLyrCount = 0;
                int i;  //临时变量
                ILayer tmpLyr;//临时变量

                //所有图层

                switch (strInText)
                {
                    case ("所有图层"):
                        //所有图层

                        for (i = 0; i < c; i++)
                        {
                            intLyrCount++;
                            altLayer.Add(m_pMapControl.get_Layer(i));
                        }
                        break;

                    default:
                        //指定图层                                    
                        for (i = 0; i < c; i++)
                        {
                            tmpLyr = m_pMapControl.get_Layer(i);
                            if (tmpLyr.Name == strInText)
                            {
                                altLayer.Add(tmpLyr);
                                intLyrCount++;
                                tmpLyr = null;
                                break;
                            }
                        }
                        break;
                }
                ////指定图层                                    
                //for (i = 0; i < c; i++)
                //{
                //    tmpLyr = m_pMapControl.get_Layer(i);
                //    if (tmpLyr.Name == strInText)
                //    {
                //        altLayer.Add(tmpLyr);
                //        intLyrCount++;
                //        tmpLyr = null;
                //        break;
                //    }
                //}

                if (intLyrCount == 0)
                {
                    MessageBox.Show("没有您要查找的图层", "查找");
                    pLayer = null;
                    altLayer = null;
                    btn_Find.Enabled = true;
                    btn_Find.Text = "查找";
                    return;
                }
                else
                {
                    pLayer = new ILayer[intLyrCount];
                    altLayer.CopyTo(pLayer);

                    for (i = 0; i < intLyrCount; i++)
                    {

                        Application.DoEvents();
                        if (m_cancelFinding)
                        {
                            pLayer = null;
                            altLayer = null;
                            btn_Find.Enabled = true;
                            btn_Find.Text = "查找";
                            return; 
                        }

                        IFeatureLayer pFLyr;
                        IFeatureClass pFeatureClass;
                        IQueryFilter pQueryFilter = (IQueryFilter)new QueryFilterClass();
                        int intFieldCount = 0;
                        string strSearchField = "";

                        IFields pFields;
                        IField pField;
                        //遍历图层
                        pFLyr = (IFeatureLayer)pLayer[i];
                        pFeatureClass = pFLyr.FeatureClass;

                        intFieldCount = pFeatureClass.Fields.FieldCount;
                        pFields = pFeatureClass.Fields;

                        string strSQL = "";

                        //设置查询条件
                        for (int j = 0; j < intFieldCount; j++)
                        {
                            pField = pFields.get_Field(j);
                            strSearchField = pField.Name;
                            bool blnFind = true;
                            string tmpSQL = "";

                            switch (pField.Type)
                            {
                                case esriFieldType.esriFieldTypeString:
                                    tmpSQL = strSearchField + " Like '%" +
                                            strFindText + "%' or " + strSearchField + " Like '*" +
                                            strFindText + "*'";
                                    break;

                                case esriFieldType.esriFieldTypeSmallInteger:
                                    if (IsNumber(strFindText))
                                        tmpSQL = strSearchField + "=" +
                                            Convert.ToInt16(strFindText);
                                    else
                                        blnFind = false;
                                    break;

                                case esriFieldType.esriFieldTypeSingle:
                                    if (IsNumber(strFindText))
                                        tmpSQL = strSearchField + "=" +
                                            Convert.ToSingle(strFindText);
                                    else
                                        blnFind = false;
                                    break;

                                case esriFieldType.esriFieldTypeOID:
                                    if (IsNumber(strFindText))
                                        tmpSQL = strSearchField + "=" +
                                            Convert.ToInt32(strFindText);
                                    else
                                        blnFind = false;
                                    break;

                                case esriFieldType.esriFieldTypeInteger:
                                    if (IsNumber(strFindText))
                                        tmpSQL = strSearchField + "=" +
                                            Convert.ToInt32(strFindText);
                                    else
                                        blnFind = false;
                                    break;

                                case esriFieldType.esriFieldTypeDouble:
                                    if (IsNumber(strFindText))
                                        tmpSQL = strSearchField + "=" +
                                            Convert.ToDouble(strFindText);
                                    else
                                        blnFind = false;
                                    break;

                                default:
                                    blnFind = false;
                                    break;

                            }//++switch

                            if (blnFind)
                            {
                                if (strSQL != "")
                                {
                                    strSQL = strSQL + " or " + tmpSQL;
                                }
                                else
                                {
                                    strSQL = tmpSQL;
                                }
                            }//++if(blnFind)                        
                        }//++for (int j = 0; j < intFieldCount; j++)

                        IFeatureCursor pFeatureCursor;
                        IFeature pFeature;
                        pQueryFilter.WhereClause = strSQL;
                        pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);
                        do
                        {
                            pFeature = pFeatureCursor.NextFeature();
                            if (pFeature != null)
                            {
                                int intC = pFeature.Fields.FieldCount;
                                for (int k = 0; k < intC; k++)
                                {
                                    string strValue = pFeature.get_Value(k).ToString();
                                    string strFieldName = pFeature.Fields.get_Field(k).AliasName.ToString();
                                    if (IsValue(strValue, strFindText))
                                    {
                                        //Console.WriteLine(strValue+","+strFieldName );
                                        ListViewItem ItmX = new ListViewItem();
                                        ItmX.Text = strValue;
                                        ItmX.SubItems.Add(pFLyr.Name.ToString());
                                        //ItmX.SubItems.Add(strFieldName);
                                        lvw_Result.Items.Add(ItmX);
                                        m_altFeatureLayer.Add(pFLyr);
                                        m_altFeature.Add(pFeature);
                                    }
                                }
                            }
                        } while (pFeature != null);

                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

                    }//++for (i = 0; i < intLyrCount; i++)

                    if (lvw_Result.Items.Count == 0)
                    {
                        MessageBox.Show("对不起，没有您要查询的结果！");
                        btn_Find.Enabled = true;
                        btn_Find.Text = "查找";
                        return;
                    }

                }//++else

                btn_Find.Enabled = true;
                btn_Find.Text = "查找";
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用FindInfo出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 判断输入的字符串与要对比的字符串是否相似
        /// <summary>
        /// 描述：判断输入的字符串与要对比的字符串是否相似

        /// </summary>
        /// <param name="strInput">输入的字符串</param>
        /// <param name="strCompare">被对比的字符串</param>
        /// <returns></returns>
        private bool IsValue(string strInput, string strCompare)
        {
            if (strInput.Contains(strCompare))
                return true;
            else
                return false;

        }
            #endregion

            #region 生成弹出菜单
        /// <summary>
        /// 描述：生成弹出菜单

        /// </summary>
        private void PopMemu(Point p)
        {
            MenuItem mnuZoomTo = new MenuItem("定位");
            MenuItem mnuIdentity = new MenuItem("信息");

            MenuItem[] mnuMain = new MenuItem[2];
            mnuMain[0] = mnuZoomTo;
            mnuMain[1] = mnuIdentity;

            System.Windows.Forms.ContextMenu CMenu = new ContextMenu(mnuMain);
            CMenu.Show(this.lvw_Result, p);

            mnuZoomTo.Click += new System.EventHandler(this.mnuZoomTo_Click);
            mnuIdentity.Click += new System.EventHandler(this.mnuIdentity_Click);

        }
            #endregion

            #region 闪亮显示
        /// <summary>
        /// 描述：闪亮显示

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Flash()
        {
            try
            {
                int intObjectIdIndex = lvw_Result.FocusedItem.Index;
                IFeature pFeature = (IFeature)m_altFeature[intObjectIdIndex];

                ESRI.ArcGIS.Geometry.IGeometry pGeometry = (ESRI.ArcGIS.Geometry.IGeometry)pFeature.Shape;
                ESRI.ArcGIS.Geometry.esriGeometryType gtm = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint;
                if (pGeometry.GeometryType == gtm)
                {
                    ESRI.ArcGIS.Geometry.IMultipoint pMP = (ESRI.ArcGIS.Geometry.IMultipoint)pGeometry;
                    ESRI.ArcGIS.Geometry.IPointCollection pPC = (ESRI.ArcGIS.Geometry.IPointCollection)pMP;
                    ESRI.ArcGIS.Geometry.IPoint pPT = pPC.get_Point(0);
                    ESRI.ArcGIS.Geometry.ITopologicalOperator pTO = (ESRI.ArcGIS.Geometry.ITopologicalOperator)pPT;
                    
                    pGeometry = pTO.Buffer(0.00001);
                    Console.WriteLine("输出：" + pGeometry.Envelope.XMax.ToString() + "," + pGeometry.Envelope.XMin.ToString());
                }
                else
                {
                    ESRI.ArcGIS.Geometry.ITopologicalOperator pTO = (ESRI.ArcGIS.Geometry.ITopologicalOperator)pGeometry;
                    pGeometry = pTO.Buffer(0.0001);
                }

                m_pMapControl.FlashShape(pGeometry);
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用Flash出错，" + ex.Message.ToString());
            }
        }
            #endregion

        #endregion

        #region 事件方法

            #region 加载窗体时发生

        /// <summary>
        /// 描述：加载窗体时发生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FindForm_Load(object sender, EventArgs e)
        {
            try
            {
                Initial();
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用FindForm_Load出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 取消
        /// <summary>
        /// 描述：

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            try
            {
                this.m_cancelFinding = true;
                this.lvw_Result.Items.Clear();
                this.Hide();
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用btn_Cancel_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 查找
        /// <summary>
        /// 描述：查找

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Find_Click(object sender, EventArgs e)
        {
            try
            {
                FindInfo();
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用btn_Find_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 查询结果的右击事件

        /// <summary>
        /// 描述：查询结果的右击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lvw_Result_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.Button == MouseButtons.Right)
                {
                    Point p = new Point(e.X, e.Y);
                    PopMemu(p);
                }
                else
                {
                    btn_Locate.Enabled = true;
                    btn_Info.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用lvw_Result_MouseClick出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 全图元显示

        /// <summary>
        /// 描述：全图元显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuZoomTo_Click(object sender, EventArgs e)
        {
            try
            {
                int intObjectIdIndex = lvw_Result.FocusedItem.Index;
                IFeature pFeature = (IFeature)m_altFeature[intObjectIdIndex];

                ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = pFeature.Shape.Envelope;
                pEnvelope.Expand(1.2, 1.2, true);
                if (pEnvelope != null)
                {
                    m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = pEnvelope;
                    m_pMapControl.ActiveView.Refresh();
                }

                //m_canFlash = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用mnuZoomTo_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 右键信息
        /// <summary>
        /// 描述：右键信息

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuIdentity_Click(object sender, EventArgs e)
        {
            try
            {
                int intObjectIdIndex = lvw_Result.FocusedItem.Index;
                IFeature pFeature = (IFeature)m_altFeature[intObjectIdIndex];
                string strLayerName = lvw_Result.FocusedItem.SubItems[1].Text.ToString();
                IFeatureLayer pFeatureLayer = (IFeatureLayer)m_altFeatureLayer[intObjectIdIndex];
                identity.Initial(pFeature, pFeatureLayer, m_pMapControl);
                identity.Show();
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用mnuIdentity_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 定位
        /// <summary>
        /// 描述：定位

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Locate_Click(object sender, EventArgs e)
        {
            try
            {
                //先全图元显示
                int intObjectIdIndex = lvw_Result.FocusedItem.Index;
                IFeature pFeature = (IFeature)m_altFeature[intObjectIdIndex];

                ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = null;
                ESRI.ArcGIS.Geometry.IGeometry pGeometry = pFeature.Shape;
                ESRI.ArcGIS.Geometry.esriGeometryType gt = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint;
                ESRI.ArcGIS.Geometry.esriGeometryType gtm = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint;
                if (pGeometry.GeometryType==gt||pGeometry.GeometryType==gtm)
                {
                    ESRI.ArcGIS.Geometry.IPolygon pPolygon = null;
                    ESRI.ArcGIS.Geometry.ITopologicalOperator pTO = null;
                    if (pGeometry.GeometryType == gtm)
                    {
                        ESRI.ArcGIS.Geometry.IMultipoint pMP = (ESRI.ArcGIS.Geometry.IMultipoint)pGeometry;
                        ESRI.ArcGIS.Geometry.IPointCollection pPC = (ESRI.ArcGIS.Geometry.IPointCollection)pMP;
                        ESRI.ArcGIS.Geometry.IPoint pPT = pPC.get_Point(0);
                        pGeometry = (ESRI.ArcGIS.Geometry.IGeometry)pPT;
                        pTO = (ESRI.ArcGIS.Geometry.ITopologicalOperator)pGeometry;
                        pPolygon = (ESRI.ArcGIS.Geometry.IPolygon)pTO.Buffer(0.0001);
                    }
                    else
                    {
                        pTO = (ESRI.ArcGIS.Geometry.ITopologicalOperator)pGeometry;
                        pPolygon = (ESRI.ArcGIS.Geometry.IPolygon)pTO.Buffer(0.001);
                    }
                    pEnvelope = pPolygon.Envelope;
                }
                else
                {
                    pEnvelope = pGeometry.Envelope;
                }

                pEnvelope.Expand(1.2, 1.2, true);
                if (pEnvelope != null)
                {
                    m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = pEnvelope;
                    m_pMapControl.ActiveView.Refresh();
                }
                //然后闪烁显示 
                tim_Flash.Enabled = true;
                //ESRI.ArcGIS.Geometry.IGeometry pGeometry = (ESRI.ArcGIS.Geometry.IGeometry)pFeature.Shape;
                //m_pMapControl.FlashShape(pGeometry);
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用btn_Locate_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 详细信息
        /// <summary>
        /// 描述：详细信息

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Info_Click(object sender, EventArgs e)
        {
            try
            {
                //显示详细信息
                int intObjectIdIndex = lvw_Result.FocusedItem.Index;
                IFeature pFeature = (IFeature)m_altFeature[intObjectIdIndex];
                string strLayerName = lvw_Result.FocusedItem.SubItems[1].Text.ToString();
                IFeatureLayer pFeatureLayer = (IFeatureLayer)m_altFeatureLayer[intObjectIdIndex];
                identity.Initial(pFeature, pFeatureLayer, m_pMapControl);
                identity.Show(); 
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用btn_Info_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 当按下回车时进行查找
        /// <summary>
        /// 描述：当按下回车时进行查找

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbb_Find_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode.Equals(Keys.Return))
                    btn_Find_Click(sender, null);
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用btn_Info_Click出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 双击查询结果
        /// <summary>
        /// 描述：双击查询结果

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lvw_Result_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                this.btn_Locate_Click(sender, e);
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用lvw_Result_DoubleClick出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region 地图视图区发生变化时发生
        /// <summary>
        /// 描述：地图视图区发生变化时发生

        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_pMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            try
            {
                //if (m_canFlash)
                //{
                    //Flash();
                    //tim_Flash.Enabled = true;
                    //m_canFlash = false;
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用m_pMapControl_OnExtentUpdated出错，" + ex.Message.ToString());
            }
        }

        private void m_pMapControl_OnAfterDraw(object sender, IMapControlEvents2_OnAfterDrawEvent e)
        {
            try
            {
                //if (m_canFlash)
                //{
                //    Flash();
                //    m_canFlash = false;
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用m_pMapControl_OnAfterDraw出错，" + ex.Message.ToString());
            }
        }
            #endregion

            #region timer
        private void tim_Flash_Tick(object sender, EventArgs e)
        {
            Flash();
            tim_Flash.Enabled = false;
        }
            #endregion


        private void FindForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                this.m_cancelFinding = true;
                this.lvw_Result.Items.Clear();
                this.Hide();
                e.Cancel = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("调用btn_Cancel_Click出错，" + ex.Message.ToString());
            }
        }
        #endregion

        #region 变量

        //添加一个属性

        private AxMapControl m_pMapControl=null;

        private System.Collections.ArrayList m_altFeatureLayer;
        private System.Collections.ArrayList m_altFeature;

        private bool m_cancelFinding = false;

        #endregion

        #region 属性


        /// <summary>
        /// 描述：要查询的地图控件

        /// </summary>
        public AxMapControl MapControl
        {
            get { return m_pMapControl; }
            set { m_pMapControl = value; }
        }

        public bool CancelFinding
        {
            get { return m_cancelFinding; }
            set { m_cancelFinding = value; }
        }
        #endregion


    }
}